import React, { Component } from 'react'
import { Button } from 'antd';
import { connect } from 'react-redux'
import { increaseNumAction, reductionNumAction } from './../../store/modules/Cart/cartActionCreate'


class Cart extends Component {
    render() {
        return (
            <div className='content'>
                <Button onClick={this.props.increaseFn}>+</Button>
                {this.props.num}
                <Button onClick={this.props.reductionFn}>-</Button>
            </div>
        )
    }
}

const stateToProps = (state) => {
    console.log('cart', state);
    return {
        num: state.cart.num
    }
}

const dispatchToProps = (dispatch) => {
    return {
        increaseFn: () => {
            dispatch(increaseNumAction())
        },
        reductionFn: () => {
            dispatch(reductionNumAction())

        }
    }
}


export default connect(stateToProps, dispatchToProps)(Cart)